
public class Power {
    /**
     * 计算x的y次方
     * @param x 底数
     * @param y 指数
     * @return x的y次方的计算结果
     */
    public static double power(double x, int y) {
        double result = 1;
        for (int i = 0; i < y; i++) {
            result *= x;
        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println("2^3 = " + power(2, 3));
        System.out.println("3^4 = " + power(3, 4));
    }
}
